package com.DuoTai;

public class Test {
    public static void main(String[] args) {
        People p1=new Teacher();
        p1.run();//父类引用子类的对象
       // p1.test();
        System.out.println(p1.name);
        People p2=new Student();
        System.out.println(p2.name);
            p2.run();
          // Student s1= (Student) p1;//学生类不能转换成老师类

           if(p1 instanceof Student){
               Student s= (Student) p1;
               s.test();
           } else if (p1 instanceof Teacher) {
               Teacher t= (Teacher) p1;
           }
           go(p2);

    }
    public static void go(People p){
        p.run();
        if(p instanceof Student){
            Student s= (Student) p;
            s.test();
        } else if (p instanceof Teacher) {
            Teacher t= (Teacher) p;
        }

    }
}
